<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /**
         *  ejs:
         *  vue:
         *  react:
         * 
         */
        var data = {
            name:'atguigu',
            age:19
        }
        var template = '<div><p>姓名：{{name}}</p><p>年龄：{{age}}</p></div>';

        var reg = /{{(.*?)}}/g;

        var result = template.replace(reg, function(item,son){
            // son 1  name
            // son 2  age
            return data[son];
        })
        console.log(result);


    </script>
</body>
</html>